#include "ST_OVER.h"
#include "Game/Game.h"
#include "Game/dConfig.h"
namespace LTGame
{
	ST_OVER::ST_OVER(GST_FLAG flag)
		: GameState(flag)
	{
		img_passbg = CCSprite::spriteWithFile("gui_pic/didi7.jpg");
		img_passbg->setPosition(ccp(S_WIDTH_HALF, S_HEIGHT_HALF));
		img_passbg->retain();

		img_over = CCSprite::spriteWithFile("gui_pic/gameover.png");
		img_over->setPosition(ccp(S_WIDTH_HALF, S_HEIGHT_HALF));
		img_over->retain();

		img_back = new Image("gui_pic/fanhui.png");
		img_back->setPosition(S_WIDTH-img_back->getImgW()/2,S_HEIGHT - img_back->getImgH()/2,img_back->getImgW(), img_back->getImgH(),0, 0, 0, NULL);

		img_overbg = CCSprite::spriteWithFile("gui_pic/dis.png");
		img_overbg->setPosition(ccp(S_WIDTH_HALF, S_HEIGHT_HALF));
		img_overbg->retain();
	}
	ST_OVER::~ST_OVER()
	{
		CC_SAFE_DELETE(img_passbg);
		CC_SAFE_DELETE(img_over);
		CC_SAFE_DELETE(img_back);
		CC_SAFE_DELETE(img_overbg);
	}
	bool ST_OVER::logic(void)
	{
		img_passbg->visit();
		img_overbg->visit();
		img_over->visit();
		return true;
	}
	void ST_OVER::paint(void)
	{
		img_back->drawPicture();
	}
	bool ST_OVER::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent)
	{
		return true;
	}
	void ST_OVER::ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent)
	{
		CCPoint point = pTouch->locationInView( pTouch->view() );
		if (CCGame->m_uiData->isPointerInBlock(point.x, point.y, Form_SetMusic,B_Form_Block_4))
		{
			CCGame->SetState(GST_MainMenu);
		}
	}
}